package top.lyc829.zzl_android.logic.network;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.Response;
import top.lyc829.zzl_android.MyApp;
import top.lyc829.zzl_android.logic.bean.ActivityBean;
import top.lyc829.zzl_android.logic.util.HttpUtil;
import top.lyc829.zzl_android.logic.util.Url;
import top.lyc829.zzl_android.logic.util.Utils;
import top.lyc829.zzl_android.logic.util.gson.JsonUtilNew;

/**
 * @Author lyc
 * @create 2021-03-15 17:04
 */
public class Network {


    /**
     * 登录方法
     * @param username 用户名
     * @param password 密码
     * @param callback 回调
     */
    public static void doLogin(String username, String password, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("account", username);
        body.put("password", password);
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.LOGIN, body, callback);
    }


    /**
     * 请求发送验证码
     * @param email 邮箱
     * @param callback 回调
     */
    public static void sendVerifyCode(String email, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("account", email);
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.SEND_VERIFY_CODE, body, callback);
    }
    /**
     * 获取用户信息
     * @param callback 回调
     */
    public static void getUserInfo(HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_INFO, callback);
    }

    public static void getConcernedInfo(int user_id,HttpUtil.MyCallback callback){
        HashMap<String, String> body = new HashMap<>();
        body.put("uesrid",String.valueOf(user_id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_CONCERNED_NUMBER,body,callback);
    }

    public static void getFansNumberInfo(int user_id,HttpUtil.MyCallback callback){
        HashMap<String,String>body=new HashMap<>();
        body.put("uesrid",String.valueOf(user_id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_FANS_NUMBER,body,callback);
    }/**
     * 发送评论接口
     * @param userId 用户id
     * @param type 评论类型 0-基地 1-动态 2-评论 3-游记
     * @param typeId 源id
     * @param text 评论文本
     * @param commentedUserId 被回复的人的id
     * @param callback 回调
     */
    public static void sendComments(int userId, int type, int typeId, String text, int commentedUserId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        body.put("text", text);
        body.put("user_id_ed", String.valueOf(commentedUserId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.COMMENT, body, callback);
    }


    /**
     * 获取关注关系（是否关注）
     * @param userId 用户id
     * @param type 关注类型 0-基地 1-动态 2-评论 3-游记
     * @param typeId 源id
     * @param callback 回调
     */
    public static void getAttentionRelationship(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_ATTENTION_RELATIONSHIP, body, callback);
    }


    /**
     * 关注
     * @param userId 用户id
     * @param type 关注类型 0-基地 1-动态 2-评论 3-游记
     * @param typeId 源id
     * @param callback 回调
     */
    public static void attention(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.ATTENTION, body, callback);
    }

    /**
     * 取消关注
     * @param userId 用户id
     * @param type 关注类型 0-基地 1-动态 2-评论 3-游记
     * @param typeId 源id
     * @param callback 回调
     */
    public static void unAttention(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.UN_ATTENTION, body, callback);
    }

    /**
     * 动态页面获取动态
     * @param page 分页
     * @param callback 回调
     */
    public static void getDynamics(int page, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("page", String.valueOf(page));
        body.put("user_id", String.valueOf(Utils.getUserId()));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_DYNAMICS, body, callback);
    }

    /**
     * 动态页面获取用户关注的用户们发的动态
     * @param page 分页
     * @param callback 回调
     */
    public static void getFellowDynamics(int page,int user_id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("page", String.valueOf(page));
        body.put("user_id", String.valueOf(user_id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_FELLOW_DYNAMICS, body, callback);
    }

    /**
     * 根据动态id获取动态
     * @param id 动态id
     * @param callback 回调
     */
    public static void getDynamicById(int id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("dynamic_id", String.valueOf(id));
        body.put("user_id", String.valueOf(Utils.getUserId()));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_DYNAMIC_BY_ID, body, callback);
    }

    /**
     * 我的页面获取我的动态
     * @param  user_id 用户id
     * @param callback 回调
     */
    public static void getUserDynamicList(int user_id,int page, HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(user_id));
        body.put("page", String.valueOf(page));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_DYNAMIC_LIST, body,callback);
    }

    /**
     * 我的页面获取我的游记
     *
     * @param  user_id 用户id
     * @param callback 回调
     */
    public static void getUserTravelsList(int user_id,HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(user_id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_TRAVELS_LIST, body,callback);
    }

    public static void getUserCollectList(int user_id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(user_id));

        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_COLLECT_LIST, body,callback);
    }
    /**
     * 获取点赞关系
     * @param userId 用户id
     * @param type 点赞类型 0-基地 1-动态 2-评论 3-游记
     * @param typeId 目的id
     * @param callback 回调
     */
    public static void getPraiseRelationShip(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_IS_PRAISE, body, callback);
    }


    /**
     * 获取一级评论
     * @param id 目的id
     * @param page 分页
     * @param type 类型 0-基地 1-动态 2-评论 3-游记
     * @param callback 回调
     */
    public static void getSuperComments(int id, int page, int type, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("type", String.valueOf(type));
        body.put("id", String.valueOf(id));
        body.put("page", String.valueOf(page));
        body.put("user_id", String.valueOf(Utils.getUserId()));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_SUPER_COMMENTS, body, callback);
    }


    /**
     * 获取N级评论
     * @param commentId 父评论id
     * @param page 分页
     * @param callback 回调
     */
    public static void getSonComments(int commentId, int page, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("comment_id", String.valueOf(commentId));
        body.put("page", String.valueOf(page));
        body.put("user_id", String.valueOf(Utils.getUserId()));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_SON_COMMENTS, body, callback);
    }

    /**
     * 发布动态
     * @param userId 用户id
     * @param text 文本
     * @param location 位置信息
     * @param isPublic 是否公开
     * @param callback 回调
     */
    public static void sendDynamic(int userId, String text, String location, boolean isPublic, HttpUtil.MyCallback callback) {
        HashMap<String, Object> body = new HashMap<>();
        body.put("user_id", userId);
        body.put("text", text);
        body.put("location", location);
        body.put("is_public", isPublic);
        String jsonBody = JsonUtilNew.mapToJson(body);

        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.postJson(Url.CREATE_DYNAMIC, jsonBody, callback);
    }


    /**
     * 获取右上角消息个数
     */
    public static void getMsgNumber(HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        HashMap<String, String> map = new HashMap<>();
        if (!Utils.isLogin()) {
            map.put("user_id", "-10");
        } else {
            map.put("user_id", String.valueOf(Utils.getUserId()));
        }
        httpUtil.get(Url.GET_MSG_NUMBERS,map, callback);
    }

    public static void clearAllMessages(HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.CLEAR_ALL_MESSAGES, callback);
    }

    public static void getTeams(int page, String location,String searchContent, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("pages", String.valueOf(page));
        if (!Utils.isStringEmpty(searchContent)) {
            body.put("search", String.valueOf(searchContent));
        }
        if (!Utils.isStringEmpty(location)) {
            body.put("location", location);
        }
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());

        httpUtil.post(Url.GET_TEAMS_MY, body, callback);
    }

    /**
     * 获取用户是否参加团队，是则返回团队id，否则返回-1
     * @param userId 用户id
     * @param callback 回调
     */
    public static void getIsInTeam(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));

        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_IS_IN_TEAM, body, callback);
    }

    public static void getFollowBaseList(int page,HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(page));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_FOLLOW_BASELIST, body, callback);
    }

    public static void getFollowTeamList(int userId, HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_FOLLOW_TEAMLIST,body, callback);
    }
    public static void getFollowUserList(int userId, HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_FOLLOW_USERLIST,body, callback);
    }
    public static void getUserFansList(int userId, HttpUtil.MyCallback callback)
    {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_USER_FANS, body,callback);
    }



    /**
     * 创建团队时搜索基地
     * @param name 基地名
     * @param type 基地类型
     * @param page 分页
     * @param callback 回调
     */
    public static void getBasesInCreateTeam(String name, int type, int page,HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("name",name);
        body.put("type",String.valueOf(type));
        body.put("page",String.valueOf(page));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.SEARCH_BASES_IN_CREATE_TEAM, body, callback);
    }

    /**
     * 创建团队
     * @param jsonStr json
     * @param callback 回调
     */
    public static void createTeam(String jsonStr, HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.postJson(Url.CREATE_TEAM, jsonStr, callback);
    }

    /**
     * 获取团队中的活动列表
     * @param teamId 团队id
     * @param callback
     */
    public static void getActivityInTeam(int teamId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id",String.valueOf(teamId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_ACTIVITY_IN_TEAM, body, callback);
    }

    /**
     * 获取我的团队中的基本信息
     * @param callback 回调
     */
    public static void getMyTeamInfo(int teamId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id",String.valueOf(teamId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_MY_TEAM_INFO, body, callback);
    }

    /**
     * 获取团队中的成员信息
     * @param teamId 团队id
     * @param callback 回调
     */
    public static void getTeamUsers(int teamId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id",String.valueOf(teamId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_TEAM_USERS, body, callback);
    }

    /**
     * 获取活动中的成员信息
     * @param teamId 团队id
     * @param callback 回调
     */
    public static void getTeamUsersInActivity(int teamId, int activityId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id",String.valueOf(teamId));
        body.put("act_id",String.valueOf(activityId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_ACTIVITY_USERS, body, callback);
    }


    /**
     * 获取用户搜索记录
     * @param userId
     * @param callback
     */
    public static void getSearchHistory(int type, int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("type", String.valueOf(type));

        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.SEARCH_HISTORY, body, callback);
    }

    /**
     * 删除搜索记录
     * @param id    搜索记录的id
     * @param callback
     */
    public static void eraseSearchHistory(int id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("search_id", String.valueOf(id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.ERASE_HISTORY, body, callback);
    }

    /**
     * 退出团队
     * @param teamId 团队id
     * @param userId 用户id
     * @param callback 回调
     */
    public static void quitTeam(int teamId, int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id", String.valueOf(teamId));
        body.put("user_id", String.valueOf(userId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.QUIT_TEAM, body, callback);
    }

    /**
     * 获取团队基本信息（不是我的团队）
     * @param teamId 团队id
     * @param callback 回调
     */
    public static void getTeamInfo(int teamId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("team_id",String.valueOf(teamId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.GET_MY_TEAM_INFO, body, callback);
    }

    /**
     * 用户申请加入团队
     * @param userId 用户id
     * @param teamId 团队id
     * @param activityId 活动id
     * @param callback 回调
     */
    public static void joinTeam(int userId, int teamId, int activityId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("team_id",String.valueOf(teamId));
        body.put("act_id",String.valueOf(activityId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.JOIN_TEAM, body, callback);
    }

    /**
     * 判断用户是否加入了该团队
     * @param userId 用户id
     * @param teamId 团队id
     * @param callback 回调
     */
    public static void isJoinTeam(int userId, int teamId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("team_id",String.valueOf(teamId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.IS_JOIN_TEAM, body, callback);
    }

    /**
     * 发布（更新游记）游记
     * @param jsonBody json请求体
     * @param callback 回调
     */
    public static void publishTravel(String jsonBody, HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.postJson(Url.ADD_TRAVEL, jsonBody, callback);
    }

    /**
     * 发布（更新游记）游记
     * @param body params
     * @param callback 回调
     */
    public static void publishTravelWithGet(HashMap<String, String> body, HttpUtil.MyCallback callback) {
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.ADD_TRAVEL, body, callback);
    }


    /**
     * 上传子游记中的图片
     * @param userId 用户名
     * @param activityId 活动id
     * @param fileList 图片file列表
     */
    public static void uploadTravelPhotos(int userId, String activityId, List<File> fileList) {

//        Map<String, String> params = new HashMap<>();
//        params.put("user_id", String.valueOf(userId));
//        params.put("activity_id", String.valueOf(activityId));
//
//        HttpUtil.getInstance(MyApp.getContext())
//                .sendMultipart(Url.UPLOAD_TRAVEL_PHOTOS, params, fileList, new HttpUtil.MyCallback() {
//                    @Override
//                    public void success(Response res) throws IOException {
//
//                    }
//
//                    @Override
//                    public void failed(IOException e) {
//
//                    }
//                });
    }


    /**
     * 获取游记列表
     * @param callback 回调
     */
    public static void loadTravels(int page, HttpUtil.MyCallback callback) {

        HashMap<String, String> body = new HashMap<>();
        body.put("page",String.valueOf(page));

        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_TRAVELS, body, callback);
    }

    /**
     * 根据游记id获取游记详情
     * @param travelId 游记id
     * @param callback 回调
     */
    public static void loadTravelDetail(int travelId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("travel_id",String.valueOf(travelId));

        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_TRAVEL_DETAIL, body, callback);
    }

    /**
     * 删除游记
     * @param userId 用户id
     * @param travelId 游记id
     * @param callback 回调
     */
    public static void deleteTravel(int userId, int travelId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("travel_id",String.valueOf(travelId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.DELETE_TRAVELS, body, callback);
    }


    /**
     * 获取评论通知
     * @param userId 用户id
     * @param callback 回调
     */
    public static void getNoticeComments(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_NOTICE_COMMENTS, body, callback);
    }

    /**
     * 根据评论id获取特定的评论
     * @param commentId 评论id
     * @param callback 回调
     */
    public static void loadCommentById(int commentId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("comment_id",String.valueOf(commentId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_COMMENT_BY_ID, body, callback);
    }

    /**
     * 获取点赞通知
     * @param userId 用户id
     * @param callback 回调
     */
    public static void loadNoticePraises(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_NOTICE_PRAISES, body, callback);
    }

    /**
     * 点赞
     * @param userId 用户id
     * @param type 类型
     * @param typeId 类型id
     * @param callback 回调
     */
    public static void sendLike(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("type",String.valueOf(type));
        body.put("type_id",String.valueOf(typeId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.SEND_PRAISE, body, callback);
    }

    /**
     * 取消点赞
     * @param userId 用户id
     * @param type 类型
     * @param typeId 类型id
     * @param callback 回调
     */
    public static void sendUnLike(int userId, int type, int typeId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("type",String.valueOf(type));
        body.put("type_id",String.valueOf(typeId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.SEND_UN_PRAISE, body, callback);
    }




    /**
     * 获取关注用户列表
     * @param userId 用户id
     * @param callback 回调
     */
    public static void loadNoticeFollowUsers(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_NOTICE_FOLLOW_USERS, body, callback);
    }

    /**
     * 获取团队申请列表
     * @param userId 用户id
     * @param callback 回调
     */
    public static void loadNoticeApply(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_NOTICE_APPLY, body, callback);
    }

    public static void handleTeamApply(int userId, int applyUserId, int result, int activityId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("apply_user_id",String.valueOf(applyUserId));
        body.put("result",String.valueOf(result));
        body.put("act_id",String.valueOf(activityId));
        HttpUtil.getInstance(MyApp.getContext()).post(Url.HANDLE_APPLY, body, callback);
    }

    /**
     * 获取系统通知列表
     * @param userId 用户id
     * @param callback 回调
     */
    public static void loadNoticeSystem(int userId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.GET_NOTICE_SYSTEM, body, callback);
    }

    /**
     * 已读某条通知
     * @param userId 用户id
     * @param id 通知id
     * @param callback 回调
     */
    public static void readNotice(int userId, int id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id",String.valueOf(userId));
        body.put("id",String.valueOf(id));
        HttpUtil.getInstance(MyApp.getContext()).get(Url.READ_NOTICE, body, callback);
    }

    /**
     *
     * @param type 搜索类型
     * @param string 搜索内容
     * @param callback
     */
    public static void getSearchDetail(int type, String string, int page, int id, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("type", String.valueOf(type));
        body.put("search_content", String.valueOf(string));
        body.put("pages",String.valueOf(page));
        body.put("user_id",String.valueOf(id));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.GET_SEARCH_DETIAL, body, callback);
    }


    /**
     * 分享到动态
     * @param type 类型 动态类型 0-基地 1-动态 2-评论 3-游记  5原动态
     * @param typeId 类型id
     * @param userId 用户id
     * @param callback 回调
     */
    public static void shareToDynamic(int type, int typeId, int userId ,String msg, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("type", String.valueOf(type));
        body.put("type_id", String.valueOf(typeId));
        body.put("user_id",String.valueOf(userId));
        body.put("text",msg);
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.SHARE_DYNAMIC, body, callback);
    }

    /**
     * 删除动态
     * @param userId 用户id
     * @param dynamicId 动态id
     * @param callback 回调
     */
    public static void deleteDynamic(int userId, int dynamicId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("dynamic_id", String.valueOf(dynamicId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.DELETE_DYNAMIC, body, callback);
    }

    /**
     * 获取收藏状态
     * @param userId 用户id
     * @param travelId 游记id
     * @param callback 回调
     */
    public static void getCollectionState(int userId, int travelId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("travel_id", String.valueOf(travelId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.COLLECTION_STATE, body, callback);
    }

    /**
     * 收藏游记
     * @param userId 用户id
     * @param travelId 游记id
     * @param callback 回调
     */
    public static void collectionTravel(int userId, int travelId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("travel_id", String.valueOf(travelId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.COLLECTION, body, callback);
    }

    /**
     * 取消收藏游记
     * @param userId 用户id
     * @param travelId 游记id
     * @param callback 回调
     */
    public static void unCollectionTravel(int userId, int travelId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        body.put("user_id", String.valueOf(userId));
        body.put("travel_id", String.valueOf(travelId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.UN_COLLECTION, body, callback);
    }

    /**
     * 删除评论
     * @param userId 用户id
     * @param commentId 评论id
     * @param callback 回调
     */
    public static void deleteComment(int userId, int commentId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        //body.put("user_id", String.valueOf(userId));
        body.put("review_id", String.valueOf(commentId));
        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.get(Url.DELETE_COMMENT, body, callback);
    }

    /**
     * 创建活动
     * @param userId 用户id
     * @param teamId 团队id
     * @param activities 活动列表
     * @param callback 回调
     */
    public static void addActivities(int userId, int teamId, List<ActivityBean> activities, HttpUtil.MyCallback callback) {

        Gson gson = new Gson();
        String jsonList = gson.toJson(activities);

//        HashMap<String, String> jsonMap = new HashMap<>();
////        jsonMap.put("user_id", String.valueOf(userId));
////        jsonMap.put("team_id", String.valueOf(teamId));
//        jsonMap.put("act_info", jsonList);

        String url = Url.CREATE_ACTIVITY + "?user_id=" + userId + "&team_id=" + teamId;

        HttpUtil.getInstance(MyApp.getContext()).postJson(url, jsonList, callback);
    }

    /**
     * 上传文件 并得到路径
     * @param file file
     * @param callback 回调
     */
    public static void uploadFileForUrl(File file, HttpUtil.MyCallback callback) {
        String url = "http://lyc829.top:8090//upload_pic";
        HttpUtil.getInstance(MyApp.getContext()).sendSingleFileWithParams(url, null, file, "file", callback);
    }


    public static void finishTeam(int userId, int teamId, int activityId, HttpUtil.MyCallback callback) {
        HashMap<String, String> body = new HashMap<>();
        //body.put("user_id", String.valueOf(userId));
        body.put("activity_id", String.valueOf(activityId));
        body.put("team_id", String.valueOf(teamId));
        body.put("user_id", String.valueOf(userId));

        HttpUtil httpUtil = HttpUtil.getInstance(MyApp.getContext());
        httpUtil.post(Url.FINISH_TEAM, body, callback);
    }

}
